/**
 * @author yxw
 * date : 2014年2月13日 上午9:31:08 
 */
package com.tzinfo.tzb.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.tzinfo.tzb.domain.ClassList.ClassData.ClassSubMenu;
import com.tzinfo.tzb.domain.DiaryList;
import com.tzinfo.tzb.domain.ForumRecommend;
import com.tzinfo.tzb.domain.ForumthreadList;
import com.tzinfo.tzb.domain.ForumthreadList.ForumthreadData;
import com.tzinfo.tzb.domain.Hot;
import com.tzinfo.tzb.domain.HotList;
import com.tzinfo.tzb.domain.NotificationList;
import com.tzinfo.tzb.domain.NotificationList.NotificationData;
import com.tzinfo.tzb.domain.Tzb_UserInfoModel;
import com.tzinfo.tzb.domain.UserList;
import com.yxw.util.OutLog;

public class TzbCommonData {
    public static ClassSubMenu classSubMenu = null;
    public static ForumthreadData forumthreadData = null;
    public static ForumthreadList forumthreadList = null;
    public static HotList hotList = null;
    /**
     * 推荐
     */
    public static ForumRecommend forumRecommend = null;

    /**
     * 发现用户： 0.附近用户  1.达人用户  2.同龄用户
     */
    public static Map<String, UserList> faxianUserMap = null;
    /**
     * 发现用户： 0.分享  1.回帖  2.关注
     */
    public static Map<String, NotificationList> notificationListMap = null;
    /**
     * 我的主页日志列表
     */
    public static DiaryList diaryList = null;
    public static int diaryItem = 0;

    /**
     * 我的个人信息
     */
    public static Tzb_UserInfoModel userInfoModel = null;

    public static int POSITION = 0;
    // 静态常量
    public final static int NOPULL_LOAD = 0;
    public final static int PULL_REFLASH = 1;
    public final static int PULL_LOAD_MORE = 2;

    public final static String IS_OK = "isOK";
    public final static String IS_NEED_REFLASH = "isNeedReflash";
    public final static String IS_DELETE = "isDelete";

    public static void initNotificationListMap(NotificationList notificationList) {
        if (notificationList != null) {
            List<NotificationData> list = notificationList.getData();
            NotificationList list1 = new NotificationList();
            NotificationList list2 = new NotificationList();
            NotificationList list3 = new NotificationList();
            List<NotificationData> listData1 = new ArrayList<NotificationData>();
            List<NotificationData> listData2 = new ArrayList<NotificationData>();
            List<NotificationData> listData3 = new ArrayList<NotificationData>();

            for (int i = 0; i < list.size(); i++) {
                OutLog.LogE("yxw", list.get(i).getType());
                if ("sharenotice".equals(list.get(i).getType().trim())) {// 关注
                    listData1.add(list.get(i));
                } else if ("post".equals(list.get(i).getType().trim())) {// 回帖
                    listData2.add(list.get(i));
                } else if ("fans".equals(list.get(i).getType().trim())) {// 分享
                    listData3.add(list.get(i));
                }
            }
            list1.setData(listData1);
            list2.setData(listData2);
            list3.setData(listData3);
            if (notificationListMap != null) {
                notificationListMap.clear();
            } else {
                notificationListMap = new HashMap<String, NotificationList>();
            }
            notificationListMap.put("0", list1);
            notificationListMap.put("1", list2);
            notificationListMap.put("2", list3);
        }

    }

    public static void addNotificationListMap(NotificationList notificationList) {
        if (notificationList != null) {
            if (notificationListMap == null) {
                notificationListMap = new HashMap<String, NotificationList>();
            }
            List<NotificationData> list = notificationList.getData();
            NotificationList list1 = notificationListMap.get("1");
            NotificationList list2 = notificationListMap.get("2");
            NotificationList list3 = notificationListMap.get("3");
            List<NotificationData> listData1 = list1.getData();
            List<NotificationData> listData2 = list2.getData();
            List<NotificationData> listData3 = list3.getData();
            for (int i = 0; i < list.size(); i++) {
                if ("sharenotice".equals(list.get(i).getType().trim())) {// 分享
                    listData1.add(list.get(i));
                } else if ("post".equals(list.get(i).getType().trim())) {// 回帖
                    listData2.add(list.get(i));
                } else if ("fans".equals(list.get(i).getType().trim())) {// 关注
                    listData3.add(list.get(i));
                }
            }
            list1.setData(listData1);
            list2.setData(listData2);
            list3.setData(listData3);
            if (notificationListMap != null) {
                notificationListMap.clear();
            } else {
                notificationListMap = new HashMap<String, NotificationList>();
            }
            notificationListMap.put("0", list1);
            notificationListMap.put("1", list2);
            notificationListMap.put("2", list3);
        }
    }
}
